import request from "@/utils/request";

/**
 * 获取商品列表数据
 * @param params
 * @deprecated 弃用了 改用getSuitGoodsList
 * @see getSuitGoodsList
 * @returns {Promise<unknown>}
 */
export function getGoodsList(params = {}){
  return request({
    url: '/goods/getGoodsList',
    method: 'get',
    params
  })
}

/**
 * 获取商品关联信息
 * @param suitId
 * @returns {Promise | Promise<unknown>}
 */
export function getGoodsSuit(suitId){
  return request({
    url: `/goods/getGoodsSuit/${suitId}`,
    method: 'get',
  });
}

/**
 * 保存商品关联
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveGoodsSuit(data){
  return request({
    url: `/goods/suitGoods`,
    method: 'post',
    data,
  })
}

/**
 * 搜索商品
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getSuitGoodsList(params = {}){
  return request({
    url: `/goods/getSuitGoodsList`,
    params
  })
}

/**
 * 保存商品尺寸
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveGoodsSize(data){
  return request({
    url: '/goods/saveGoodsSize',
    data,
    method: 'put',
  })
}

/**
 * 保存商品尺寸
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveGoodsSizeV2(data){
  return request({
    url: '/goods/saveGoodsSizeV2',
    data,
    method: 'put',
  })
}

/**
 * 同步希音商品
 * @returns {Promise | Promise<unknown>}
 */
export function syncSheinGoods(){
  return request({
    url: '/goods/syncSheinGoods',
    handleError: true,
  })
}


/**
 * 获取当前采集状态是否完成
 * @returns {Promise | Promise<unknown>}
 */
export function sheinGoodsCollectIsDone(){
  return request({
    url: '/goods/sheinGoodsCollectIsDone',
    handleError: true,
  })
}

export function getGoodsOptions(){
  return request({
    url: '/common/getGoodsAttrOptions',
  })
}
